clear all 
log using "/Users/abhram/Library/CloudStorage/Dropbox/Research/trA/replication/table_1.log", replace   

******************************************************************** 
********     TABLE 1:  IVQR BY DECADE                        ********
******************************************************************** 




*** Decade 1 ('80s) *** 


use "Duranton_Turner_AER_2010.dta", clear


	* Selection of observations
	drop if l_ln_km_IH_83==0

	rename sprawl_1992 sprawl_1993
	rename sprawl_1976 sprawl_1983
	gen sprawl_2003 = sprawl_1993

	*rescale so display is better
	replace elevat_range_msa = elevat_range_msa/1000 
	replace ruggedness_msa = ruggedness_msa/1000
	replace heating_dd = heating_dd/100
	replace cooling_dd = cooling_dd/100

      rename S_somecollege_80 S_somecollege_1983
      rename S_somecollege_00 S_somecollege_2003
      rename S_somecollege_90 S_somecollege_1993
      rename S_poor_80 S_poor_1983
      rename S_poor_90 S_poor_1993
      rename S_poor_00 S_poor_2003
      rename l_mean_income_80 l_mean_income_1983
      rename l_mean_income_90 l_mean_income_1993
      rename l_mean_income_00 l_mean_income_2003
      rename S_manuf83 S_manuf_1983
      rename S_manuf93 S_manuf_1993
      rename S_manuf03 S_manuf_2003
      rename S_truck83 S_truck_1983
      rename S_truck93 S_truck_1993
      rename S_truck03 S_truck_2003
      gen l_pop_1983 = l_pop80 
      gen l_pop_1993 = l_pop90 
      gen l_pop_2003 = l_pop00 

      rename l_max_84bus l_bus_1983 
      rename l_max_94bus l_bus_1993 
      rename l_max_04bus l_bus_2003 
      rename l_transit84 l_transit_1983
      rename l_transit94 l_transit_1993 
      rename l_transit04 l_transit_2003

      rename l_ln_km_IHU_83 l_ln_km_IHU_1983
      rename l_ln_km_IHU_93 l_ln_km_IHU_1993
      rename l_ln_km_IHU_03 l_ln_km_IHU_2003
      rename l_ln_km_IH_83 l_ln_km_IH_1983
      rename l_ln_km_IH_93 l_ln_km_IH_1993
      rename l_ln_km_IH_03 l_ln_km_IH_2003
      rename l_ln_km_MRU_83 l_ln_km_MRU_1983
      rename l_ln_km_MRU_93 l_ln_km_MRU_1993
      rename l_ln_km_MRU_03 l_ln_km_MRU_2003
      
      rename l_vmt_IHU_83 l_vmt_IHU_1983
      rename l_vmt_IHU_93 l_vmt_IHU_1993
      rename l_vmt_IHU_03 l_vmt_IHU_2003
      rename l_vmt_IH_83 l_vmt_IH_1983
      rename l_vmt_IH_93 l_vmt_IH_1993
      rename l_vmt_IH_03 l_vmt_IH_2003
      rename l_vmt_MRU_83 l_vmt_MRU_1983
      rename l_vmt_MRU_93 l_vmt_MRU_1993
      rename l_vmt_MRU_03 l_vmt_MRU_2003



	reshape long l_ln_km_IH  l_ln_km_IHU  l_ln_km_IHNU  l_ln_km_MRU l_vmt_IH l_vmt_IHU  l_vmt_IHNU  l_vmt_MRU l_bus l_transit sprawl S_somecollege l_mean_income S_poor S_manuf S_truck l_pop, i(msa ) j(year _1983 _1993 _2003)

	local geography	 "elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl"
	local demographics "S_somecollege l_mean_income S_poor S_manuf"  
	local census_div "div1 div2 div3 div4 div5 div6 div7 div8 div9"
	local population "l_pop80 l_pop70 l_pop60 l_pop50 l_pop40 l_pop30 l_pop20"  


	


		local Inst "l_rail1898 l_hwy1947"
		capture drop l_vmt l_ln
		gen l_vmt = l_vmt_IH  
		gen l_ln  = l_ln_km_IH 

		keep if year == "_1983" 

* Model 1 *

		ivregress liml l_vmt (l_ln = l_rail1898 l_hwy1947) if year == "_1983", robust       
 
		ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) if year == "_1983",  quantile(10 25 50 75 90) vce(robust)    
		
		estat endogeffects, rseed(123456789) 
		estat endogeffects, rseed(123456789) level(90)  
		

* Model 2 *

		ivregress liml l_vmt l_pop (l_ln = l_rail1898 l_hwy1947) if year == "_1983", robust      
		  
		 ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) l_pop if year == "_1983",  quantile(10 25 50 75 90) vce(robust) 
		 
		 estat endogeffects, rseed(123456789) 
		 estat endogeffects, rseed(123456789) level(90) 
		 


* Model 3 *

		ivregress liml l_vmt l_pop elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl div2 div3 div4 div5 div6 div7 div8 div9 (l_ln = l_rail1898 l_hwy1947) if year == "_1983", robust      
		 
		ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) l_pop elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl div2 div3 div4 div5 div6 div7 div8 div9 if year == "_1983",  quantile(10 25 50 75 90) vce(robust) 	
		
		estat endogeffects, rseed(123456789) 
		estat endogeffects, rseed(123456789) level(90) 	
	

* Model 4 *

		ivregress liml l_vmt l_pop S_somecollege l_mean_income S_poor S_manuf div2 div3 div4 div5 div6 div7 div8 div9 elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl (l_ln = l_rail1898 l_hwy1947) if year == "_1983", robust      
		 
		ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) l_pop S_somecollege l_mean_income S_poor S_manuf div2 div3 div4 div5 div6 div7 div8 div9 elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl if year == "_1983",  quantile(10 25 50 75 90) vce(robust) 
		
		estat endogeffects, rseed(123456789) 
		estat endogeffects, rseed(123456789) level(90) 
		
		
* Model 5 * 

		ivregress liml l_vmt l_pop l_pop80 l_pop70 l_pop60 l_pop50 l_pop40 l_pop30 l_pop20 S_somecollege l_mean_income S_poor S_manuf div2 div3 div4 div5 div6 div7 div8 div9 elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl (l_ln = l_rail1898 l_hwy1947) if year == "_1983", robust 
		
		ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) l_pop l_pop80 l_pop70 l_pop60 l_pop50 l_pop40 l_pop30 l_pop20 S_somecollege l_mean_income S_poor S_manuf div2 div3 div4 div5 div6 div7 div8 div9 elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl if year == "_1983",  quantile(10 25 50 75 90) vce(robust) 
		
		estat endogeffects, rseed(123456789) 
		estat endogeffects, rseed(123456789) level(90) 
		
		
		
		
		
		
*** Decade 2 ('90s) *** 


use "Duranton_Turner_AER_2010.dta", clear


	* Selection of observations
	drop if l_ln_km_IH_83==0

	rename sprawl_1992 sprawl_1993
	rename sprawl_1976 sprawl_1983
	gen sprawl_2003 = sprawl_1993

	*rescale so display is better
	replace elevat_range_msa = elevat_range_msa/1000 
	replace ruggedness_msa = ruggedness_msa/1000
	replace heating_dd = heating_dd/100
	replace cooling_dd = cooling_dd/100

      rename S_somecollege_80 S_somecollege_1983
      rename S_somecollege_00 S_somecollege_2003
      rename S_somecollege_90 S_somecollege_1993
      rename S_poor_80 S_poor_1983
      rename S_poor_90 S_poor_1993
      rename S_poor_00 S_poor_2003
      rename l_mean_income_80 l_mean_income_1983
      rename l_mean_income_90 l_mean_income_1993
      rename l_mean_income_00 l_mean_income_2003
      rename S_manuf83 S_manuf_1983
      rename S_manuf93 S_manuf_1993
      rename S_manuf03 S_manuf_2003
      rename S_truck83 S_truck_1983
      rename S_truck93 S_truck_1993
      rename S_truck03 S_truck_2003
      gen l_pop_1983 = l_pop80 
      gen l_pop_1993 = l_pop90 
      gen l_pop_2003 = l_pop00 

      rename l_max_84bus l_bus_1983 
      rename l_max_94bus l_bus_1993 
      rename l_max_04bus l_bus_2003 
      rename l_transit84 l_transit_1983
      rename l_transit94 l_transit_1993 
      rename l_transit04 l_transit_2003

      rename l_ln_km_IHU_83 l_ln_km_IHU_1983
      rename l_ln_km_IHU_93 l_ln_km_IHU_1993
      rename l_ln_km_IHU_03 l_ln_km_IHU_2003
      rename l_ln_km_IH_83 l_ln_km_IH_1983
      rename l_ln_km_IH_93 l_ln_km_IH_1993
      rename l_ln_km_IH_03 l_ln_km_IH_2003
      rename l_ln_km_MRU_83 l_ln_km_MRU_1983
      rename l_ln_km_MRU_93 l_ln_km_MRU_1993
      rename l_ln_km_MRU_03 l_ln_km_MRU_2003
      
      rename l_vmt_IHU_83 l_vmt_IHU_1983
      rename l_vmt_IHU_93 l_vmt_IHU_1993
      rename l_vmt_IHU_03 l_vmt_IHU_2003
      rename l_vmt_IH_83 l_vmt_IH_1983
      rename l_vmt_IH_93 l_vmt_IH_1993
      rename l_vmt_IH_03 l_vmt_IH_2003
      rename l_vmt_MRU_83 l_vmt_MRU_1983
      rename l_vmt_MRU_93 l_vmt_MRU_1993
      rename l_vmt_MRU_03 l_vmt_MRU_2003



	reshape long l_ln_km_IH  l_ln_km_IHU  l_ln_km_IHNU  l_ln_km_MRU l_vmt_IH l_vmt_IHU  l_vmt_IHNU  l_vmt_MRU l_bus l_transit sprawl S_somecollege l_mean_income S_poor S_manuf S_truck l_pop, i(msa ) j(year _1983 _1993 _2003)

	local geography	 "elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl"
	local demographics "S_somecollege l_mean_income S_poor S_manuf"  
	local census_div "div1 div2 div3 div4 div5 div6 div7 div8 div9"
	local population "l_pop80 l_pop70 l_pop60 l_pop50 l_pop40 l_pop30 l_pop20"  





		local Inst "l_rail1898 l_hwy1947"
		capture drop l_vmt l_ln
		gen l_vmt = l_vmt_IH  
		gen l_ln  = l_ln_km_IH 

		keep if year == "_1993" 

		local Inst "l_rail1898 l_hwy1947"
		capture drop l_vmt l_ln
		gen l_vmt = l_vmt_IH  
		gen l_ln  = l_ln_km_IH 

		

* Model 1 *

		ivregress liml l_vmt (l_ln = l_rail1898 l_hwy1947) if year == "_1993", robust       
 
		ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) if year == "_1993",  quantile(10 25 50 75 90) vce(robust)   
		
		estat endogeffects, rseed(123456789) 
		estat endogeffects, rseed(123456789) level(90) 


* Model 2 *

		ivregress liml l_vmt l_pop (l_ln = l_rail1898 l_hwy1947) if year == "_1993", robust      
		  
		 ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) l_pop if year == "_1993",  quantile(10 25 50 75 90) vce(robust) 
		 
		 estat endogeffects, rseed(123456789) 
		 estat endogeffects, rseed(123456789) level(90) 


* Model 3 *

		ivregress liml l_vmt l_pop elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl div2 div3 div4 div5 div6 div7 div8 div9 (l_ln = l_rail1898 l_hwy1947) if year == "_1993", robust      
		 
		ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) l_pop elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl div2 div3 div4 div5 div6 div7 div8 div9 if year == "_1993",  quantile(10 25 50 75 90) vce(robust) 
		
		estat endogeffects, rseed(123456789) 
		estat endogeffects, rseed(123456789) level(90) 	
	

* Model 4 *

		ivregress liml l_vmt l_pop S_somecollege l_mean_income S_poor S_manuf div2 div3 div4 div5 div6 div7 div8 div9 elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl (l_ln = l_rail1898 l_hwy1947) if year == "_1993", robust      
		 
		ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) l_pop S_somecollege l_mean_income S_poor S_manuf div2 div3 div4 div5 div6 div7 div8 div9 elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl if year == "_1993",  quantile(10 25 50 75 90) vce(robust) 
		
		estat endogeffects, rseed(123456789) 
		estat endogeffects, rseed(123456789) level(90) 
		
		
* Model 5 * 

		ivregress liml l_vmt l_pop l_pop80 l_pop70 l_pop60 l_pop50 l_pop40 l_pop30 l_pop20 S_somecollege l_mean_income S_poor S_manuf div2 div3 div4 div5 div6 div7 div8 div9 elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl (l_ln = l_rail1898 l_hwy1947) if year == "_1993", robust 
		
		ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) l_pop l_pop80 l_pop70 l_pop60 l_pop50 l_pop40 l_pop30 l_pop20 S_somecollege l_mean_income S_poor S_manuf div2 div3 div4 div5 div6 div7 div8 div9 elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl if year == "_1993",  quantile(10 25 50 75 90) bound(0 6) vce(robust) 
		
		estat endogeffects, rseed(123456789) 
		estat endogeffects, rseed(123456789) level(90) 

		
		
		
*** Decade 3 ('00s) *** 


use "Duranton_Turner_AER_2010.dta", clear


	* Selection of observations
	drop if l_ln_km_IH_83==0

	rename sprawl_1992 sprawl_1993
	rename sprawl_1976 sprawl_1983
	gen sprawl_2003 = sprawl_1993

	*rescale so display is better
	replace elevat_range_msa = elevat_range_msa/1000 
	replace ruggedness_msa = ruggedness_msa/1000
	replace heating_dd = heating_dd/100
	replace cooling_dd = cooling_dd/100

      rename S_somecollege_80 S_somecollege_1983
      rename S_somecollege_00 S_somecollege_2003
      rename S_somecollege_90 S_somecollege_1993
      rename S_poor_80 S_poor_1983
      rename S_poor_90 S_poor_1993
      rename S_poor_00 S_poor_2003
      rename l_mean_income_80 l_mean_income_1983
      rename l_mean_income_90 l_mean_income_1993
      rename l_mean_income_00 l_mean_income_2003
      rename S_manuf83 S_manuf_1983
      rename S_manuf93 S_manuf_1993
      rename S_manuf03 S_manuf_2003
      rename S_truck83 S_truck_1983
      rename S_truck93 S_truck_1993
      rename S_truck03 S_truck_2003
      gen l_pop_1983 = l_pop80 
      gen l_pop_1993 = l_pop90 
      gen l_pop_2003 = l_pop00 

      rename l_max_84bus l_bus_1983 
      rename l_max_94bus l_bus_1993 
      rename l_max_04bus l_bus_2003 
      rename l_transit84 l_transit_1983
      rename l_transit94 l_transit_1993 
      rename l_transit04 l_transit_2003

      rename l_ln_km_IHU_83 l_ln_km_IHU_1983
      rename l_ln_km_IHU_93 l_ln_km_IHU_1993
      rename l_ln_km_IHU_03 l_ln_km_IHU_2003
      rename l_ln_km_IH_83 l_ln_km_IH_1983
      rename l_ln_km_IH_93 l_ln_km_IH_1993
      rename l_ln_km_IH_03 l_ln_km_IH_2003
      rename l_ln_km_MRU_83 l_ln_km_MRU_1983
      rename l_ln_km_MRU_93 l_ln_km_MRU_1993
      rename l_ln_km_MRU_03 l_ln_km_MRU_2003
      
      rename l_vmt_IHU_83 l_vmt_IHU_1983
      rename l_vmt_IHU_93 l_vmt_IHU_1993
      rename l_vmt_IHU_03 l_vmt_IHU_2003
      rename l_vmt_IH_83 l_vmt_IH_1983
      rename l_vmt_IH_93 l_vmt_IH_1993
      rename l_vmt_IH_03 l_vmt_IH_2003
      rename l_vmt_MRU_83 l_vmt_MRU_1983
      rename l_vmt_MRU_93 l_vmt_MRU_1993
      rename l_vmt_MRU_03 l_vmt_MRU_2003



	reshape long l_ln_km_IH  l_ln_km_IHU  l_ln_km_IHNU  l_ln_km_MRU l_vmt_IH l_vmt_IHU  l_vmt_IHNU  l_vmt_MRU l_bus l_transit sprawl S_somecollege l_mean_income S_poor S_manuf S_truck l_pop, i(msa ) j(year _1983 _1993 _2003)

	local geography	 "elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl"
	local demographics "S_somecollege l_mean_income S_poor S_manuf"  
	local census_div "div1 div2 div3 div4 div5 div6 div7 div8 div9"
	local population "l_pop80 l_pop70 l_pop60 l_pop50 l_pop40 l_pop30 l_pop20"  


	



		local Inst "l_rail1898 l_hwy1947"
		capture drop l_vmt l_ln
		gen l_vmt = l_vmt_IH  
		gen l_ln  = l_ln_km_IH 

		keep if year == "_2003" 

		local Inst "l_rail1898 l_hwy1947"
		capture drop l_vmt l_ln
		gen l_vmt = l_vmt_IH  
		gen l_ln  = l_ln_km_IH 

		

* Model 1 *

		ivregress liml l_vmt (l_ln = l_rail1898 l_hwy1947) if year == "_2003", robust       
 
		ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) if year == "_2003",  quantile(10 25 50 75 90) vce(robust)   
		
		estat endogeffects, rseed(123456789) 
		estat endogeffects, rseed(123456789) level(90) 


* Model 2 *

		ivregress liml l_vmt l_pop (l_ln = l_rail1898 l_hwy1947) if year == "_2003", robust      
		  
		 ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) l_pop if year == "_2003",  quantile(10 25 50 75 90) vce(robust) 
		 
		 estat endogeffects, rseed(123456789) 
		 estat endogeffects, rseed(123456789) level(90) 


* Model 3 *

		ivregress liml l_vmt l_pop elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl div2 div3 div4 div5 div6 div7 div8 div9 (l_ln = l_rail1898 l_hwy1947) if year == "_2003", robust      
		 
		ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) l_pop elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl div2 div3 div4 div5 div6 div7 div8 div9 if year == "_2003",  quantile(10 25 50 75 90) vce(robust) 	
		
		estat endogeffects, rseed(123456789) 
		estat endogeffects, rseed(123456789) level(90) 	
	

* Model 4 *

		ivregress liml l_vmt l_pop S_somecollege l_mean_income S_poor S_manuf div2 div3 div4 div5 div6 div7 div8 div9 elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl (l_ln = l_rail1898 l_hwy1947) if year == "_2003", robust      
		 
		ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) l_pop S_somecollege l_mean_income S_poor S_manuf div2 div3 div4 div5 div6 div7 div8 div9 elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl if year == "_2003",  quantile(10 25 50 75 90) vce(robust) 
		
		estat endogeffects, rseed(123456789) 
		estat endogeffects, rseed(123456789) level(90) 
		
		
* Model 5 * 

		ivregress liml l_vmt l_pop l_pop80 l_pop70 l_pop60 l_pop50 l_pop40 l_pop30 l_pop20 S_somecollege l_mean_income S_poor S_manuf div2 div3 div4 div5 div6 div7 div8 div9 elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl (l_ln = l_rail1898 l_hwy1947) if year == "_2003", robust 
		
		ivqregress iqr l_vmt (l_ln = l_rail1898 l_hwy1947) l_pop l_pop80 l_pop70 l_pop60 l_pop50 l_pop40 l_pop30 l_pop20 S_somecollege l_mean_income S_poor S_manuf div2 div3 div4 div5 div6 div7 div8 div9 elevat_range_msa ruggedness_msa heating_dd cooling_dd sprawl if year == "_2003",  quantile(10 25 50 75 90) ngrid(100) vce(robust) 
		
		estat endogeffects, rseed(123456789) 
		estat endogeffects, rseed(123456789) level(90) 
		
		
log off 		
